PER.rover
Class CreepAction

java.lang.Object
  extended byPER.rover.CreepAction
All Implemented Interfaces:
Action, java.io.Serializable

public class CreepAction
extends java.lang.Object
implements Action

Drives the trikebot a specified distance at a specified angle and speed. This action is different from the DriveToAction in that it uses Omnidirectional steering rather than Ackerman steering. The changes in speed are roughly, but not exactly, linear. Therefor, the rover will drive at the specified speed, but the distance covered will only be approximate and will vary slightly depending on the speed. For a set cm distance, the actual distance covered will be more for slower speeds and less for faster speeds.

See Also:
Serialized Form

Field Summary
static byte CYCLE_SAFETY
          The safety level where the rover will pan its head back and forth to scan for obstacles in its path
static byte NO_SAFETY
          The safety level where no obstacle checking is done
static byte STATIC_SAFETY
          The safety level where the rover will check for obstacles with its head fixed at pan=angle of travel, tilt=-35 degrees
 
Constructor Summary
CreepAction(int dist, int ang, double speed)
          Creates a new CreepAction that does not take pictures and has safety turned off.
CreepAction(int dist, int ang, double speed, boolean takePics)
          Creates a new CreepAction with saftey turned off.
CreepAction(int dist, int ang, double speed, byte safetyLevel, boolean takePics)
          Creates a new CreepAction with the specified safety level.
CreepAction(int dist, int ang, double speed, byte safetyLevel, int pan, int tilt)
          Creates a new CreepAction with the specified safety level that takes pictures at the given pan and tilt.
 
Method Summary
 boolean doAction(Rover r)
          Tries to start the action.
 long getImageUpdateTime()
          Lets you know when the last image was taken by this action.
 java.awt.image.BufferedImage getRecentImage()
          Returns the most recent image taken by this Action.
 int getReturnValue()
          Returns SUCCESS if the rover drove the entire distance without detecting an obstacle or error.
 java.lang.String getShortSummary()
          Provides a shortened version of the summary returned by getSummary.
 java.lang.String getSummary()
          Provides a textual explanation of the Action, such as "turn 90 degrees"
 int getTime()
          Returns how long the action took to complete the last time it was executed (in milliseconds), or how long the action is expected to take if it has never been executed.
 int getTimeRemaining()
          How much time until the action finishes (in milliseconds), if it has already started.
 boolean isCompleted()
          Whether the action has completed.
 boolean isSuccess()
          Returns true if the rover drove the entire distance without detecting an obstacle or error.
 void kill()
          Emergency stop - end the action immediately, if it's running.
 void setAngle(int ang)
          Sets the angle to the given degree (0=straight, 90=left, -90=right).
 void setDistance(int distance)
          Sets the distance to the given cm value and recalculates how long the action will take.
 void setPictureAngles(int pan, int tilt)
          Sets the pan and tilt angles to be used when taking a picture.
 void setSafetyLevel(byte level)
          Sets the safety level to be used when driving.
 void setSpeed(int s)
          Sets the speed to the given percent, where 0 is stopped and 1 is full speed.
 void setTakePictures(boolean takePictures)
          Turns picture taking on or off.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_SAFETY

public static final byte NO_SAFETY
The safety level where no obstacle checking is done

See Also:
Constant Field Values

CYCLE_SAFETY

public static final byte CYCLE_SAFETY
The safety level where the rover will pan its head back and forth to scan for obstacles in its path

See Also:
Constant Field Values

STATIC_SAFETY

public static final byte STATIC_SAFETY
The safety level where the rover will check for obstacles with its head fixed at pan=angle of travel, tilt=-35 degrees

See Also:
Constant Field Values
Constructor Detail

CreepAction

public CreepAction(int dist,
                   int ang,
                   double speed)
Creates a new CreepAction that does not take pictures and has safety turned off.

Parameters:
dist - centimeters to move
ang - the angle to drive at. The minimum angle is -90 and the maximum angle is 90. Anything outside this range will be set to the closest valid value. (0=straight, 90=left, -90=right)
speed - the speed to drive at. Should be between 0 and 1, where 0 is stopped and 1 is full speed. Anything less than 0 will be treated as 0. Anything greater than 1 will be treated as 1.

CreepAction

public CreepAction(int dist,
                   int ang,
                   double speed,
                   boolean takePics)
Creates a new CreepAction with saftey turned off. If the rover is taking pictures, use getRecentImage to get the pictures taken while the rover is driving. Pictures will be taken at pan = angle of travel and tilt = 0.

Parameters:
dist - centimeters to move
ang - the angle to drive at. The minimum angle is -90 and the maximum angle is 90. Anything outside this range will be set to the closest valid value. (0=straight, 90=left, -90=right)
speed - the speed to drive at. Should be between 0 and 1, where 0 is stopped and 1 is full speed. Anything less than 0 will be treated as 0. Anything greater than 1 will be treated as 1.
takePics - if true, the rover will take pictures as it drives
See Also:
getRecentImage(), getImageUpdateTime()

CreepAction

public CreepAction(int dist,
                   int ang,
                   double speed,
                   byte safetyLevel,
                   boolean takePics)
Creates a new CreepAction with the specified safety level. If the rover is taking pictures, use getRecentImage to get the pictures taken while the rover is driving. Pictures will be taken at pan = angle of travel and tilt = 0.

Parameters:
dist - centimeters to move
ang - the angle to drive at. The minimum angle is -90 and the maximum angle is 90. Anything outside this range will be set to the closest valid value. (0=straight, 90=left, -90=right)
speed - the speed to drive at. Should be between 0 and 1, where 0 is stopped and 1 is full speed. Anything less than 0 will be treated as 0. Anything greater than 1 will be treated as 1.
safetyLevel - CYCLE_SAFETY, STATIC_SAFETY, or NO_SAFETY
takePics - if true, the rover will take pictures as it drives
See Also:
getRecentImage(), getImageUpdateTime()

CreepAction

public CreepAction(int dist,
                   int ang,
                   double speed,
                   byte safetyLevel,
                   int pan,
                   int tilt)
Creates a new CreepAction with the specified safety level that takes pictures at the given pan and tilt. Use getRecentImage to get the pictures taken while the rover is driving.

The STATIC_SAFETY level does not work well when combined with a pan other than the angle of travel or a tilt other than -35.

Parameters:
dist - centimeters to move
ang - the angle to drive at. The minimum angle is -90 and the maximum angle is 90. Anything outside this range will be set to the closest valid value. (0=straight, 90=left, -90=right)
speed - the speed to drive at. Should be between 0 and 1, where 0 is stopped and 1 is full speed. Anything less than 0 will be treated as 0. Anything greater than 1 will be treated as 1.
safetyLevel - CYCLE_SAFETY, STATIC_SAFETY, or NO_SAFETY
pan - The pan angle (in degrees) to position the head at when taking pictures. This value should be in the range of [-180, 180]. If you choose an angle outside of this range, the pan will be set to the closest valid value. Positive angles are to the left.
tilt - The tilt angle (in degrees) to position the head at when taking pictures. This value should be in the range of [-50, 90]. If you choose an angle outside of this range, the tilt will be set to the closest valid value.
See Also:
getRecentImage(), getImageUpdateTime()
Method Detail

setDistance

public void setDistance(int distance)
Sets the distance to the given cm value and recalculates how long the action will take.


setAngle

public void setAngle(int ang)
Sets the angle to the given degree (0=straight, 90=left, -90=right). The minimum angle is -90 and the maximum angle is 90. Anything outside of this range will be set to the nearest valid value.


setSpeed

public void setSpeed(int s)
Sets the speed to the given percent, where 0 is stopped and 1 is full speed. Anything outside of this range will be set to the nearest valid value. Also recalculates how long the action will take.


setSafetyLevel

public void setSafetyLevel(byte level)
Sets the safety level to be used when driving. Valid options are CYCLE_SAFETY, STATIC_SAFETY, or NO_SAFETY. Any other value will be set to NO_SAFETY.

Parameters:
level - CYCLE_SAFETY, STATIC_SAFETY, or NO_SAFETY

setTakePictures

public void setTakePictures(boolean takePictures)
Turns picture taking on or off.

Parameters:
takePictures - true to turn on picture taking, false to turn picture taking off.

setPictureAngles

public void setPictureAngles(int pan,
                             int tilt)
Sets the pan and tilt angles to be used when taking a picture.

Parameters:
pan - The pan angle (in degrees) to position the head at when taking pictures. This value should be in the range of [-180, 180]. If you choose an angle outside of this range, the pan will be set to the closest valid value. Positive angles are to the left.
tilt - The tilt angle (in degrees) to position the head at when taking pictures. This value should be in the range of [-50, 90]. If you choose an angle outside of this range, the tilt will be set to the closest valid value.

doAction

public boolean doAction(Rover r)
Description copied from interface: Action
Tries to start the action. Returns whether the action started.

Specified by:
doAction in interface Action

getTime

public int getTime()
Returns how long the action took to complete the last time it was executed (in milliseconds), or how long the action is expected to take if it has never been executed. Note that setDistance and setSpeed recalculate the expected time based on the new distance or new speed. Calling getTime after a call to setDistance or setSpeed will return the new expected time.

Specified by:
getTime in interface Action

getSummary

public java.lang.String getSummary()
Description copied from interface: Action
Provides a textual explanation of the Action, such as "turn 90 degrees"

Specified by:
getSummary in interface Action

getShortSummary

public java.lang.String getShortSummary()
Description copied from interface: Action
Provides a shortened version of the summary returned by getSummary. For example, getSummary may return something like "Turn left and drive about 39 inches toward the red landmark," whereas getShortSummary might just return "Drive toward a landmark."

Specified by:
getShortSummary in interface Action

getReturnValue

public int getReturnValue()
Returns SUCCESS if the rover drove the entire distance without detecting an obstacle or error. Otherwise, returns the appropriate status code.

Specified by:
getReturnValue in interface Action
See Also:
RoverState

isSuccess

public boolean isSuccess()
Returns true if the rover drove the entire distance without detecting an obstacle or error. Undefined until isCompleted() returns true.

Specified by:
isSuccess in interface Action

getRecentImage

public java.awt.image.BufferedImage getRecentImage()
Description copied from interface: Action
Returns the most recent image taken by this Action. The image will be null if the Action does not take pictures or the first picture has not yet been taken.

Specified by:
getRecentImage in interface Action
Returns:
the most recent picture taken by the Action.

getImageUpdateTime

public long getImageUpdateTime()
Description copied from interface: Action
Lets you know when the last image was taken by this action. If the Action does not take pictures or the first picture has not yet been taken, will return 0.

Specified by:
getImageUpdateTime in interface Action
Returns:
the system time in milliseconds when the last image was taken or 0 if no images have been taken

isCompleted

public boolean isCompleted()
Description copied from interface: Action
Whether the action has completed. Undefined until doAction has been called.

Specified by:
isCompleted in interface Action

kill

public void kill()
Description copied from interface: Action
Emergency stop - end the action immediately, if it's running.

Specified by:
kill in interface Action

getTimeRemaining

public int getTimeRemaining()
Description copied from interface: Action
How much time until the action finishes (in milliseconds), if it has already started. Undefined behavior if the action has not yet begun, or has finished.

Specified by:
getTimeRemaining in interface Action